<template>
  <div class="tabbar-wrapper">
    <div class="tabbar-content">
      <p>欢迎来到叩丁严选</p>
      <div>
        <ul>
          <li>
            <img
              :src="
                userInfo
                  ? userInfo.headImg
                  : require('../assets/img/userImg.f8bbec5e.png')
              "
              alt=""
            />
            <span>用户名: {{ userInfo ? userInfo.nickName : "--" }}</span>
          </li>
          <li>我的鸡腿: {{ userInfo ? userInfo.coin : "--" }}</li>
          <li>获取鸡腿</li>
          <li>叩丁狼官网</li>
          <li class="cartTotal" v-if="userInfo">
            购物车
            <span class="circle">
              {{ cartTotal }}
            </span>
          </li>
          <li v-else class="tabbar-login" @click="loginFn">登录</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import bus from "../bus";

export default {
  methods: {
    loginFn() {
      bus.$emit("loginshow", true);
    },
  },
  computed: {
    userInfo() {
      return this.$store.state.userInfo?.userInfo;
    },
    cartTotal() {
      return this.$store.state.userInfo?.cartTotal;
    },
  },
};
</script>

<style lang="less" scoped>
.tabbar-wrapper {
  height: 40px;
  width: 100%;
  background-color: #242b39;
  .tabbar-content {
    display: flex;
    width: 1200px;
    height: 100%;
    justify-content: space-between;
    color: #fff;
    margin: 0 auto;
    font-size: 14px;
    align-items: center;
    ul {
      display: flex;
      align-items: center;
      li {
        &:nth-child(1) {
          display: flex;
          align-items: center;
        }
        margin-right: 20px;
        .cartTotal {
          display: flex;
          align-items: center;
          position: relative;
          padding: 0 25px;
          height: 40px;
          margin-right: 0;
          background: #0a328e;
          .circle {
            margin-left: 5px;
            display: inline-block;
            width: 22px;
            height: 22px;
            line-height: 22px;
            border-radius: 11px;
            background: red;
            text-align: center;
          }
        }
        img {
          width: 26px;
          border-radius: 13px;
          margin-right: 5px;
        }
      }
      .tabbar-login {
        height: 40px;
        width: 124px;
        line-height: 40px;
        text-align: center;
        background-color: #0a328e;
        cursor: pointer;
      }
    }
  }
}
</style>
